import { GetPlayListDetail } from "apis/index";
import { convertUnit } from "utils/index";
Page({
  data: {
    id: "",
    isFixed: false,
    list: [],
    info: {},
  },

  onLoad(options) {
    const { id } = options;
    this.setData({ id });
    this.getList();
  },
  onPullDownRefresh() {
    wx.stopPullDownRefresh();
  },
  onShareAppMessage() {},
  onScroll(e) {
    const scrollTop = convertUnit(e.detail.scrollTop, "pxToRpx");
    this.setData({
      isFixed: scrollTop >= 350,
    });
  },
  getList() {
    const { id } = this.data;
    GetPlayListDetail({ id }).then((res) => {
      console.log(res.playlist, "res---");
      const { tracks, tags, name, description, coverImgUrl } = res.playlist;
      this.setData({
        list: tracks || [],
        info: {
          name,
          tags,
          desc: description,
          img: coverImgUrl,
        },
      });
    });
  },
});
